package org.usyk.combinatorics;

import java.util.Arrays;

/**
 * Created by IntelliJ IDEA.
 * User: Алексейка
 * Date: 19.02.12
 * Time: 13:05
 * To change this template use File | Settings | File Templates.
 */
public class PositionalNotationUtil {

    /**
     * Converts decimal number to numerical system with base = systemBase
     * @param num
     * @param systemBase
     * @return
     */
    public static String numberInNumSystem(long num, int systemBase){
        StringBuilder result = new StringBuilder(systemBase);
        while (num / systemBase != 0) {
            result.append(num % systemBase);
            num = num / systemBase;
        }
        result.append(num % systemBase);
        if (result.length() < systemBase) {
            char[] array = new char[systemBase-result.length()];
            Arrays.fill(array,'0');
            result.append(array);
        }
        return  result.reverse().toString();
    }

    public static void main(String[] args) {
        long tick = System.currentTimeMillis();
        for (int i = 0; i < 4*4*4*4; i++) {
            System.out.println(numberInNumSystem(i, 4));
            for (int j = 0; j < 6*6*6*6*6*6; j++) {
//                System.out.println(numberInNumSystem(j, 6));
//                numberInNumSystem(j, 6);
            }

//            long tack = System.currentTimeMillis();
//            System.out.println(tack-tick);
        }
//        for (int i = 0; i < 6*6*6*6*6*6; i++) {
//            System.out.println(numberInNumSystem(i, 6));
//        }
        long tack = System.currentTimeMillis();
        System.out.println(tack - tick);
    }
    
}
